package tasks.OpportunitiesBaseData.MainView;
import java.sql.SQLException;
import java.util.ArrayList;

import resources.tasks.OpportunitiesBaseData.MainView.ITSDBWrapperHelper;
import tasks.OpportunitiesBaseData.ContentRule;
import tasks.OpportunitiesBaseData.Pattern;

import dbops.SQLOperator;
/**
 * Description   : Functional Test Script
 * @author angel.tsvetkov
 */
public class ITSDBWrapper extends ITSDBWrapperHelper
{
	public ITSLayout get(String detailNumber)
	{
		ITSLayout layout = new ITSLayout();
		
		ContentRule rule = new ContentRule("MainView\\ITSMainView.sql");
		SQLOperator query = new SQLOperator();
		
		ArrayList<ArrayList<String>> dbContentTmp = new ArrayList<ArrayList<String>>();
		try {
			dbContentTmp = query.executeSelect(rule.getRule(new Pattern("%OPP_DTL_KEY%",detailNumber)));
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		ArrayList<String> row = dbContentTmp.get(0);


		layout.setRepInput(row.get(ITSColumns.RepInput.ordinal()));

		layout.setGeo(row.get(ITSColumns.Geo.ordinal()));

		layout.setImt(row.get(ITSColumns.IMT.ordinal()));

		layout.setSeller(row.get(ITSColumns.Seller.ordinal()));

		layout.setOwner(row.get(ITSColumns.Owner.ordinal()));

		layout.setQtrInd(row.get(ITSColumns.QtrInd.ordinal()));

		layout.setDecWkorFcstWk(row.get(ITSColumns.DecWkorFcstWk.ordinal()));

		layout.setProdlvl30(row.get(ITSColumns.ProdLvl30.ordinal()));

		layout.setOppNo(row.get(ITSColumns.OppNo.ordinal()));

		layout.setDtlKey(row.get(ITSColumns.DtlKey.ordinal()));

		layout.setCustName(row.get(ITSColumns.CustName.ordinal()));

		layout.setCustNo(row.get(ITSColumns.CustNo.ordinal()));

		layout.setOwnOrg(row.get(ITSColumns.OwnOrg.ordinal()));

		layout.setOppSource(row.get(ITSColumns.OppSource.ordinal()));

		layout.setOppName(row.get(ITSColumns.OppName.ordinal()));

		layout.setSsCode(row.get(ITSColumns.SSCode.ordinal()));

		layout.setSsName(row.get(ITSColumns.SSName.ordinal()));

		layout.setDtlOdds(row.get(ITSColumns.DtlOdds.ordinal()));

		layout.setDtlRev(row.get(ITSColumns.DtlRev.ordinal()));

		layout.setOppRole(row.get(ITSColumns.OppRole.ordinal()));

		layout.setSiebelPVStatus(row.get(ITSColumns.SiebelPVStatus.ordinal()));

		layout.setPrismPVStatus(row.get(ITSColumns.PRISMPVStatus.ordinal()));
		
		layout.setDecDate(row.get(ITSColumns.DecDate.ordinal()));
		
		layout.setServiceLine(row.get(ITSColumns.ServiceLine.ordinal()));
		
		layout.setSpl(row.get(ITSColumns.SPL.ordinal()));
		
		layout.setTotalOppVal(row.get(ITSColumns.TotalOppVal.ordinal()));
		
		layout.setProjectedYield(row.get(ITSColumns.ProjectedYield.ordinal()));
		
		layout.setCoseInd(row.get(ITSColumns.CoseInd.ordinal()));
		
		layout.setSdInd(row.get(ITSColumns.SDInd.ordinal()));
		
		return layout;
	}
}

